using System;
using System.ComponentModel;

namespace ErrorDumper.Providing {
    [Serializable]
    public class ExceptionQuery {
        public ListSortDirection Sort { get; set; }

        DateTime? _writeUtcFrom;
        DateTime? _writeUtcTo;

        public DateTime? WriteUtcFrom {
            get { return _writeUtcFrom; }
            set {
                if (value.HasValue) {
                    if (value.Value.Kind == DateTimeKind.Unspecified)
                        throw new ArgumentException("Argument must be utc or local kind", "value");
                    _writeUtcFrom = value.Value.ToUniversalTime();
                }
                else
                    _writeUtcFrom = null;
            }
        }

        public DateTime? WriteUtcTo {
            get { return _writeUtcTo; }
            set {
                if (value.HasValue) {
                    if (value.Value.Kind == DateTimeKind.Unspecified)
                        throw new ArgumentException("Argument must be utc or local kind", "value");
                    _writeUtcTo = value.Value.ToUniversalTime();
                }
                else
                    _writeUtcTo = null;
            }
        }

        readonly ExceptionFilter _filter = new ExceptionFilter();
        public ExceptionFilter Filter { get { return _filter; } }

        public int Skip { get; set; }
        public int Take { get; set; }
    }
}